<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.CreateCarShowAllLink}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <p:dataTable value="#{carController.items}" var="car" paginator="true" paginatorPosition="bottom">
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_registrationNumber}"/>
                        </f:facet>
                        <h:outputText value="#{car.registrationNumber}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_model}"/>
                        </f:facet>
                        <h:outputText value="#{car.model}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_brand}"/>
                        </f:facet>
                        <h:outputText value="#{car.brand}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_colour}"/>
                        </f:facet>
                        <h:outputText value="#{car.colour}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_kind}"/>
                        </f:facet>
                        <h:outputText value="#{car.kind}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_insurance}"/>
                        </f:facet>
                        <h:outputText value="#{car.insurance}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_kilometers}"/>
                        </f:facet>
                        <h:outputText value="#{car.kilometers}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.ListCarTitle_price}"/>
                        </f:facet>
                        <h:outputText value="#{car.price}"/>
                    </p:column>
                    <p:column rendered="#{request.isUserInRole('admin')}">
                        <f:facet name="header">
                            <h:outputText value="&nbsp;"/>
                        </f:facet>
                        <h:commandLink action="#{carController.prepareView(car)}" value="#{bundle.ListCarViewLink}"/>
                        <h:outputText value=" "/>
                        <h:commandLink action="#{carController.prepareEdit(car)}" value="#{bundle.ListCarEditLink}"/>
                        <h:outputText value=" "/>
                        <h:commandLink action="#{carController.destroy(car)}" value="#{bundle.ListCarDestroyLink}"/>
                    </p:column>
                </p:dataTable>
                <br />
                <h:commandLink action="#{carController.prepareCreate}" value="#{bundle.ListCarCreateLink}" rendered="#{request.isUserInRole('admin')}"/>
            </h:form>
            <h:link value="Create a car reservation " outcome="/carreservation/Create" />
        </ui:define>
    </ui:composition>    
</html>
